package com.dreamcode.caloriestracker.utils;

public class MathBodyComp{

    public static double CalcBMI(double d, double d1)
    {
        double d2 = 0.0D;
        d2 = d1 / (d * d);
        return d2;
    }

    public static double CalcBMIWeight(double d, double d1)
    {
        double d2 = 0.0D;
        d2 = d * (d1 * d1);
        return d2;
    }

    public static double CalcBodyFatCircumference(boolean flag, double d, double d1, double d2, double d3, double d4, double d5)
    {
        double d6 = 0.0D;
        if(flag)
        {
            if(d1 == 0.0D || d3 == 0.0D || d4 == 0.0D || d5 == 0.0D)
                d6 = 0.0D;
            else
                d6 = (1.2114200000000002D + 0.00085000000000000006D * d5) - 0.00050000000000000001D * d4 - 0.00061000000000000008D * d3 - 0.0013800000000000002D * d1;
        } else
        if(d == 0.0D || d1 == 0.0D || d2 == 0.0D || d3 == 0.0D)
            d6 = 0.0D;
        else
            d6 = ((((1.1682970000000001D - 0.0028240000000000006D * d1) + 1.22098E-005D * (d1 * d1)) - 0.00073312799999999999D * d3) + 0.00051047699999999996D * d2) - 0.00021616100000000001D * d;
        double d7 = ConvertBodyDensityToPercentFat(d6);
        if(d7 < 0.0D)
            d7 = 0.0D;
        return d7;
    }

    public static double CalcBodyFatYmca(double d, double d1, boolean flag, boolean flag1)
    {
        if(flag)
        {
            d = MathConvert.ConvertMetersToInches(d);
            d1 = MathConvert.ConvertKgsToLbs(d1);
        }
        double d2;
        if(flag1)
            d2 = ((-98.420000000000002D + 4.1500000000000004D * d) - 0.082000000000000017D * d1) / d1;
        else
            d2 = ((-76.760000000000005D + 4.1500000000000004D * d) - 0.082000000000000017D * d1) / d1;
        return d2;
    }

    public static double CalcBodyFatYmcaWeight(double d, double d1, boolean flag, boolean flag1)
    {
        if(flag)
            d1 = MathConvert.ConvertMetersToInches(d1);
        double d2;
        if(flag1)
            d2 = ((d + 98.420000000000002D) - 4.1500000000000004D * d1) / -0.082000000000000017D;
        else
            d2 = ((d + 76.760000000000005D) - 4.1500000000000004D * d1) / -0.082000000000000017D;
        if(flag)
            d2 = MathConvert.ConvertLbsToKgs(d2);
        return d2;
    }

    public static double CalcOptimumWeight(double d, double d1, double d2)
    {
        double d3 = d * (1.0D - d1);
        double d4 = d3 / (1.0D - d2);
        if(d <= 0.0D || d1 < 0.0D || d2 < 0.0D)
            d4 = 0.0D;
        return d4;
    }

    public static double CalcWaistToHipRatio(double d, double d1)
    {
        double d2 = 0.0D;
        if(d != 0.0D && d1 != 0.0D)
            d2 = d / d1;
        return d2;
    }

    public static double ConvertBodyDensityToPercentFat(double d)
    {
        double d1 = 0.0D;
        if(d != 0.0D)
            d1 = 495D / d - 450D;
        return d1;
    }

    public static String GetBMITerm(double d)
    {
        String s;
        if(d < 18.5D)
            s = "Underweight";
        else
        if(d < 25D)
            s = "Normal";
        else
        if(d < 30D)
            s = "Overweight";
        else
        if(d < 35D)
            s = "Obese Class I";
        else
        if(d < 40D)
            s = "Obese Class II";
        else
        if(d >= 40D)
            s = "Obese Class III";
        else
            s = "";
        return s;
    }

    public static String GetBodyFatTerm(boolean flag, double d)
    {
        String s = "";
        if(flag)
        {
            if(d < 2D)
                s = "Too Low";
            else
            if(d < 5D)
                s = "Essential";
            else
            if(d < 14D)
                s = "Athletes";
            else
            if(d < 18D)
                s = "Fitness";
            else
            if(d < 25D)
                s = "Acceptable";
            else
                s = "Obese";
        } else
        if(d < 10D)
            s = "Too Low";
        else
        if(d < 13D)
            s = "Essential";
        else
        if(d < 21D)
            s = "Athletes";
        else
        if(d < 25D)
            s = "Fitness";
        else
        if(d < 32D)
            s = "Acceptable";
        else
            s = "Obese";
        return s;
    }

    public static String GetWastToHipRatioTerm(boolean flag, double d, double d1)
    {
        String s = "Undefined";
        String s1 = "Low";
        String s2 = "Moderate";
        String s3 = "High";
        String s4 = "Very High";
        if(d == 0.0D || d1 == 0.0D)
            return s;
        if(d >= 20D)
            if(d < 30D)
            {
                if(flag)
                {
                    if(d1 < 0.83000000000000007D)
                        s = s1;
                    else
                    if(d1 < 0.89000000000000001D)
                        s = s2;
                    else
                    if(d1 <= 0.94000000000000006D)
                        s = s3;
                    else
                        s = s4;
                } else
                if(d1 < 0.70999999999999996D)
                    s = s1;
                else
                if(d1 < 0.78000000000000003D)
                    s = s2;
                else
                if(d1 <= 0.82000000000000006D)
                    s = s3;
                else
                    s = s4;
            } else
            if(d < 40D)
            {
                if(flag)
                {
                    if(d1 < 0.83999999999999997D)
                        s = s1;
                    else
                    if(d1 < 0.92000000000000004D)
                        s = s2;
                    else
                    if(d1 <= 0.95999999999999996D)
                        s = s3;
                    else
                        s = s4;
                } else
                if(d1 < 0.71999999999999997D)
                    s = s1;
                else
                if(d1 < 0.79000000000000004D)
                    s = s2;
                else
                if(d1 <= 0.83999999999999997D)
                    s = s3;
                else
                    s = s4;
            } else
            if(d < 50D)
            {
                if(flag)
                {
                    if(d1 < 0.88D)
                        s = s1;
                    else
                    if(d1 < 0.95999999999999996D)
                        s = s2;
                    else
                    if(d1 <= 1.0D)
                        s = s3;
                    else
                        s = s4;
                } else
                if(d1 < 0.72999999999999998D)
                    s = s1;
                else
                if(d1 < 0.80000000000000004D)
                    s = s2;
                else
                if(d1 <= 0.87D)
                    s = s3;
                else
                    s = s4;
            } else
            if(d < 60D)
            {
                if(flag)
                {
                    if(d1 < 0.90000000000000002D)
                        s = s1;
                    else
                    if(d1 < 0.96999999999999997D)
                        s = s2;
                    else
                    if(d1 <= 1.02D)
                        s = s3;
                    else
                        s = s4;
                } else
                if(d1 < 0.73999999999999999D)
                    s = s1;
                else
                if(d1 < 0.82000000000000006D)
                    s = s2;
                else
                if(d1 <= 0.88D)
                    s = s3;
                else
                    s = s4;
            } else
            if(d < 70D)
                if(flag)
                {
                    if(d1 < 0.91000000000000003D)
                        s = s1;
                    else
                    if(d1 < 0.98999999999999999D)
                        s = s2;
                    else
                    if(d1 <= 1.03D)
                        s = s3;
                    else
                        s = s4;
                } else
                if(d1 < 0.76000000000000001D)
                    s = s1;
                else
                if(d1 < 0.83999999999999997D)
                    s = s2;
                else
                if(d1 <= 0.90000000000000002D)
                    s = s3;
                else
                    s = s4;
        return s;
    }
}